<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@include file="/taglibs.jsp"%>
<!doctype html>
<html>
<head>
    <meta charset="UTF-8">  
    <meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
    <link href="${ctx}/resources/semanticui/semantic.min.css" rel="stylesheet" type="text/css" />
    <link href="${ctx}/resources/apps.css" rel="stylesheet" type="text/css" />
    <title>推荐他人</title>  
</head>
<body>
<div class="ui segment" id="n-page">

        <div class="ui segment" id="n-content">
            <form class="ui form">
                
                
                <div class="field">
                    <label>手机号码</label>
                    <div class="ui input">
                        <input type="text" name="phone" id="phone" placeholder="请输入您需要筛选的手机号" value="">
                    </div>
                    <label style="padding-top:5px;">注：输入手机号码查询候选人是否已被推荐过</label>
                </div>
                <input type="hidden" name="jobId" id="jobId" value="${jobId}"/>
            </form>        
        </div>
        <!--
        <div class="ui segment" id="btn-next2">
            <div class="fluid ui button" id="next">下一步</div>
        </div>
        -->
        <div class="ui center aligned segment" id="choice-buttons"> 
            <div class="two ui buttons"> 
                <div class="ui button active dog" id="next">查询</div> 
                <div class="ui button active dog" id="recommand">推荐他人</div> 
            </div>
        </div>
</div>

<script src="${ctx}/resources/jweixin-1.0.0.js"></script>

<script src="${ctx}/resources/semanticui/jquery-2.1.4.min.js"></script>
<script src="${ctx}/resources/semanticui/semantic.js" type="text/javascript"></script>
<script type="text/javascript">

    var handler = { 
        activate: function() { 
            $(this).addClass('active').siblings().removeClass('active'); 
        } 
    };

    $(document).ready(function() { 
    	$("#recommand").click(function(){
   		  var jobId = $("#jobId").val();
          $(this).addClass('disabled');
          location.href =  '${ctx}/wechat/headhunter/toRecommend.do?jobId='+jobId; 
    	});
        
    	$("#next").click(function(){
    		
            var phone = $("#phone").val();
            if(!phone || phone =="") {
              alert("您必须输入手机号码");
              return false;
	        }
	        var regEx = /^1[0-9]{2}[0-9]{8}$/;
	        if (!phone.match(regEx)) {
	            alert("您必须输入合格的手机号码");
	            return false;
	        }
            $(this).addClass('disabled');
            var that = this;

            var postUrl = '${ctx}/wechat/headhunter/existPhone.do';
            var param = {};
            param['phone']  = phone;

            $.ajax({ 
                url: postUrl, 
                type: "POST", 
                data: param,
                success: function(data) { 
                    if(data.errorcode=="0"){
                    	alert(data.msg);
                        return;
                    }else{
                        alert(data.msg);
                        return;
                    }
                }, 
                error: function(){ 
                    alert("服务出错，请稍后尝试"); 
                    $(that).removeClass('disabled');
                } 
            });
    		
    	});
    	
        wx.ready(function() {
            $('.button').on('click', handler.activate);

            wx.hideOptionMenu();
        });
    });

</script>
</body>
</html>